# schemas/participant.py
from pydantic import Field
from typing import Union
from fastapi import Query
from datetime import datetime

from admin.schemas.base import CamelModel


class ParticipantListIn(CamelModel):
    meeting_id: Union[int, None] = Field(default=None, title="会议ID")

    class Config:
        from_attributes = True
        field_operator_mapping = {
            "meeting_id": "=",
        }


class ParticipantDetailIn(CamelModel):
    id: int = Query(..., gt=0)


class ParticipantAddIn(CamelModel):
    meeting_id: int = Field(..., gt=0)
    display_name: str = Field(...)


class ParticipantEditIn(ParticipantAddIn):
    id: int = Field(..., gt=0)


class ParticipantDelIn(CamelModel):
    id: int = Field(..., gt=0)


class ParticipantOut(CamelModel):
    id: int
    meeting_id: int
    user_id: Union[int, None] = None
    display_name: Union[str, None] = None
    role: Union[str, None] = None
    joined_at: Union[datetime, None] = None

    class Config:
        from_attributes = True
